package package_test.service;

/**
 * @author colorful@TaleLin
 */
public class EnumDemo1 {

    /**
     * 性别枚举类
     */
    static class Sex {

        // 定义常量
        private final String sexName;

        // 私有化构造器，不提供外部实例化
        private Sex(String sexName) {
            // 在构造器中为属性赋值
            this.sexName = sexName;
        }

        public static final Sex MALE = new Sex("男");
        public static final Sex FEMALE = new Sex("女");
        public static final Sex UNKNOWN = new Sex("保密");

        /**
         * getter
         */
        public String getSexName() {
            return sexName;
        }

        /**
         * 重写toString方法，方便外部打印调试
         */
        @Override
        public String toString() {
            return "Sex{" +
                    "sexName='" + sexName + '\'' +
                    '}';
        }
    }

    public static void main(String[] args) {
        System.out.println(Sex.FEMALE.getSexName());
        System.out.println(Sex.MALE.getSexName());
        System.out.println(Sex.UNKNOWN.getSexName());
    }

}
